import datetime
import os.path
import sys

from charset_normalizer import detect
from requests import options
from selenium import webdriver
from selenium.webdriver.ie.service import Service
from webdriver_manager.chrome import ChromeDriverManager


class Driver:
    driver = ""
    def __init__(self):

        options = webdriver.ChromeOptions()
        self.driver = webdriver.Chrome(service = Service(ChromeDriverManager().install()),options= options)
        self.driver.implicitly_wait(3)

    #创建屏幕截图
    def DribverScreeShot(self):
        testdir = datetime.datetime.now().strftime('%Y-%m-%d')
        if not os.path.exists("../imges./"+testdir):
            os.mkdir("../imges/"+testdir)
        testShot = "../imges/"+testdir+'/'+sys._getframe().f_back.f_code.co_name +datetime.datetime.now().strftime('%Y-%m-%d-%H%M%S')+".png"
        self.driver.save_screenshot(testShot)
        
FormDriver = Driver()